<template>
    <div>
        <h1>显示</h1>
        标题:<input type="text" v-model="infoo.title">
        栏目分类:  <select v-model="infoo.lid">
            <option value="">请选择</option>
            <option :value="item.pid" v-for="item in level" :key="item.pid">{{item.pname}}</option>  
        </select>
        <input type="button" value="查询" @click="GetList">
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>标题</td>
                    <td>栏目分类</td>
                    <td>副标题</td>
                    <td>文档标签</td>
                    <td>图片</td>
                    <td>价格</td>
                    <td>颜色</td>
                    <td>发行日期</td>
                    <td>操作</td>
                </tr>
                <tr v-for="value in infoo.list">
                    <td>{{value.title}}</td>
                    <td>{{value.pname}}</td>
                    <td>{{value.otitle}}</td>
                    <td>{{value.tips}}</td>
                    <td><img :src="value.img"></td>
                    <td>{{value.money}}</td>
                    <td>{{value.color}}</td>
                    <td>{{value.time.substr(0,10)}}</td>
                    <td><input type="button" value="修改" @click="Update(value.id)"></td>
                </tr>
            </tbody>
        </table>
    </div>
    <div>
        <span>总条数:{{infoo.totalnum}}</span>
        <span>总页数:{{infoo.totalpage}}</span>
        <span>当前页:{{info.pageindex}}</span>
            <input type="button" value="首页">
            <input type="button" value="上一页">
            <input type="button" value="下一页">
            <input type="button" value="尾页">
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import {ref} from 'vue'
import { onMounted } from 'vue';
import { useRoute,useRouter } from 'vue-router';

let route=useRoute();
let router=useRouter();

onMounted(()=>{
    GetList();
     getlevel();
})


let level:any=ref([]);

let info:any=ref({
    pageindex:"",
    pagesize:""
})
let infoo:any=ref({
    lid:"",
    title:"",
    list:[],
    totalnum:"",
    totalpage:"",
})
const Update=(id:any)=>{
    router.push({
        path:'/Update',
        query:{
            id:id
        }
    })
}
const getlevel=()=>{
    axios({
        url:'https://localhost:7022/api/Phone/PhoneLevel',
        method:'get',
    })
    .then((res)=>{
        console.log(res);
        level.value=res.data
    })
    .catch((err)=>{
        console.log(err);
    })
}
const GetList=()=>{
    axios({
        url:'https://localhost:7022/api/Phone/ShowPhone',
        method:'get',
        params:infoo.value
    })
    .then((res)=>[
        console.log(res),
        Object.assign(infoo.value,res.data)  

    ])
    .catch((err)=>{
        console.log(err)
    })
}

</script>

<style scoped>

</style>